import requests


class SendMessages:
    def __init__(self):
        self._ua = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'
        }

    # 发送短信公共类
    def send_msg_common(self, url, data = None, headers = None, json_data = None, cookie = None):
        if headers is None:
            headers = self._ua
        response = requests.post(url, headers = headers, data = data, json = json_data, cookies = cookie).json()
        return response

    # 天启HTTP短信
    def y_www_tianqiip_com(self, num):
        url = 'https://www.tianqiip.com/api/registerCode'
        response = self.send_msg_common(url = url, data = {"phone": num})
        if response['code'] == 200:
            return "天启HTTP短信发送成功"
        else:
            return "天启HTTP短信发送失败"


if __name__ == '__main__':
    a = SendMessages()
    a.www_tianqiip_com('18171759943')
